{include file="public/layout" /}
<body class="bodystyle" style="cursor: default; -moz-user-select: inherit;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            {if condition="$Request.param.pid > 0"}
            <a class="back" href="{:url('Citysite/index', ['pid'=>$parentInfo.parent_id])}" title="返回列表"><i class="fa fa-angle-double-left"></i>返回</a>
            {else /}
            <a class="back" href="{:url('Index/switch_map')}" title="返回列表"><i class="fa fa-angle-double-left"></i>返回</a>
            {/if}
            <ul class="tab-base nc-row">
                <li><a href="{:url('Citysite/index')}" class="tab current"><span>多城市站点</span></a></li>
            </ul>
        </div>
    </div>
    <div class="flexigrid">
        <div class="mDiv">
            <div class="ftitle">
                {eq name="'Citysite@add'|is_check_access" value="1"}
                <div class="fbutton">
                    <a href="javascript:void(0);" data-href="{:url('Citysite/add', ['pid'=>$parentInfo.id])}" onclick="openFullframe(this, '新增区域');">
                        <div class="add" title="新增区域">
                            <span><i class="layui-icon layui-icon-addition"></i>新增区域</span>
                        </div>
                    </a>
                </div>
                {/eq}
                {eq name="'Citysite@conf'|is_check_access" value="1"}
                <div class="fbutton">
                    <a href="javascript:void(0);" data-href="{:url('Citysite/conf')}" onclick="openFullframe(this, '功能配置');">
                        <div class="add" title="功能配置">
                            <span>功能配置</span>
                        </div>
                    </a>
                </div>
                {/eq}
            </div>
            <!-- <div title="刷新数据" class="pReload"><i class="fa fa-refresh"></i></div> -->
            <form class="navbar-form form-inline" action="{:url('Citysite/index')}" method="get" onsubmit="layer_loading('正在处理');">
                {$searchform.hidden|default=''}
                <div class="sDiv">
                    <div class="sDiv2 fl" style="margin-right: 6px;">
                        <input type="text" size="30" name="keywords" value="{$Request.param.keywords}" class="qsbox" placeholder="搜索名称...">
                        <input type="submit" class="btn" value="搜索">
						<i class="fa fa-search"></i>
                    </div>
                </div>
            </form>
        </div>
        <div class="hDiv">
            <div class="hDivBox">
                <table cellspacing="0" cellpadding="0" style="width: 100%">
                    <thead>
                    <tr>
                        <th class="sign w40" axis="col0">
                            <div class="tc"><input type="checkbox" class="checkAll"></div>
                        </th>
                        <th abbr="article_show" axis="col5" class="w40">
                            <div class="tc">ID</div>
                        </th>
                        <th abbr="ac_id" axis="col4">
                            <div class="text-l10">区域名称</div>
                        </th>
                        <th abbr="article_time" axis="col6" class="w120">
                            <div class="tc">二级域名</div>
                        </th>
                        <th abbr="article_title" axis="col3" class="w160">
                            <div class="tc">上级区域</div>
                        </th>
                        <th abbr="article_time" axis="col6" class="w60">
                            <div class="tc">启用</div>
                        </th>
                        <th abbr="article_time" axis="col6" class="w50">
                            <div class="tc">层级</div>
                        </th>
                        <th axis="col1" class="w220">
                            <div class="tc">操作</div>
                        </th>
                        <th abbr="article_show" axis="col5" class="w60">
                            <div class="tc">排序</div>
                        </th>
                    </tr>
                    </thead>
                </table>
            </div>
        </div>
        <div class="bDiv" style="height: auto;">
            <div id="flexigrid" cellpadding="0" cellspacing="0" border="0">
                <table style="width: 100%">
                    <tbody>
                    {empty name="list"}
                        <tr>
                            <td class="no-data" align="center" axis="col0" colspan="50">
                                <i class="fa fa-exclamation-circle"></i>没有符合条件的记录
                            </td>
                        </tr>
                    {else/}
                        {foreach name="list" item="vo" key="k" }
                        <tr>
                            <td class="sign">
                                <div class="w40 tc"><input type="checkbox" name="ids[]" value="{$vo.id}"></div>
                            </td>
                            <td class="sort">
                                <div class="w40 tc">
                                    {$vo.id}
                                </div>
                            </td>
                            <td style="width: 100%">
                                <div class="text-l10">
                                    {eq name="'Citysite@edit'|is_check_access" value="1"}
                                    <input style="text-align: left;" type="text" onchange="changeTableVal('citysite','id','{$vo.id}','name',this);" value="{$vo.name}" />
                                    {else /}
                                    {$vo.name}
                                    {/eq}
                                </div>
                            </td>
                            <td class="">
                                <div class="w120 tc">
                                    {empty name='$vo.is_open'}——{else/}{$vo.domain}{/empty}
                                </div>
                            </td>
                            <td class="">
                                <div class="w160 tc">
                                    {empty name='$parentInfo.name'}无{else/}{$parentInfo.name}{/empty}
                                </div>
                            </td>
                            <td>
                                <div class="tc w60">
                                    {if condition="$vo['status'] eq 1"}
                                        <span class="yes" data-value="0" data-id="{$vo.id}" {eq name="'Citysite@edit'|is_check_access" value="1"}onClick="setStatus(this);"{/eq}><i class="fa fa-check-circle"></i>是</span>
                                    {else /}
                                        <span class="no" data-value="1" data-id="{$vo.id}" {eq name="'Citysite@edit'|is_check_access" value="1"}onClick="setStatus(this);"{/eq}><i class="fa fa-ban"></i>否</span>
                                    {/if}
                                </div>
                            </td>
                            <td class="">
                                <div class="w50 tc">
                                    {$vo.level}
                                </div>
                            </td>
                            <td class="operation">
                                <div class="w220 tc">
                                    {eq name="$Think.const.CONTROLLER_NAME.'@edit'|is_check_access" value="1"}
                                    <a href="javascript:void(0);" data-href="{:url('Citysite/edit',array('id'=>$vo['id']))}" class="btn blue" onclick="openFullframe(this, '编辑区域');">编辑</a>
                                    <i></i>
                                    {/eq}

                                    {lt name='$vo.level' value='3'}
                                    <a href="{:url('Citysite/index',array('pid'=>$vo['id']))}" class="btn blue">查看下级</a>
                                    {else /}
                                    <a href="javascript:void(0);" class="btn grey">查看下级</a>
                                    {/lt}
<!--                                    <i></i>
 
                                    {if condition="($vo.is_default eq 1)"}
                                    <a class="btn grey"  href="javascript:void(0);">默认区域</a>
                                    {else /}
                                    <a class="btn blue" href="javascript:;" onClick="changeSortOrder('{$vo.id}');">设为默认</a>
                                    {/if}
 -->
                                    {eq name="$Think.const.CONTROLLER_NAME.'@del'|is_check_access" value="1"}
                                    <i></i>
                                    <a class="btn red" href="javascript:void(0)" data-url="{:url('Citysite/del')}" data-id="{$vo.id}" onClick="delfun(this);">删除</a>
                                    {/eq}
                                    <i></i>
                                    <a href="{$vo.siteurl}" class="btn blue" target="_blank">预览</a>
                                </div>
                            </td>
							<i></i>
                            <td class="sort">
                                <div class="w60 tc">
                                    {eq name="'Citysite@edit'|is_check_access" value="1"}
                                    <input style="text-align: left;" type="text" onchange="changeTableVal('citysite','id','{$vo.id}','sort_order',this);" size="4"  value="{$vo.sort_order}" />
                                    {else /}
                                    {$vo.sort_order}
                                    {/eq}
                                </div>
                            </td>
                        </tr>
                        {/foreach}
                    {/empty}
                    </tbody>
                </table>
            </div>
            <div class="iDiv" style="display: none;"></div>
        </div>
        <div class="tDiv">
            <div class="tDiv2">
                <div class="fbutton checkboxall">
                    <input type="checkbox" class="checkAll">
                </div>
                {eq name="'Citysite@del'|is_check_access" value="1"}
                <div class="fbutton">
                    <a onclick="batch_del(this, 'ids');" data-url="{:url('Citysite/del')}" class="layui-btn layui-btn-primary">
                            <span>批量删除</span>
                    </a>
                </div>
                {/eq}
                <a href="JavaScript:void(0);" onclick="click_to_eyou_1575506523('https://www.eyoucms.com/plus/view.php?aid=11842','citysite 多城市站点列表标签调用')" style="font-size: 12px;padding-left: 10px;position:absolute;top: 18px">标签教程？</a>
				{include file="public/page" /}
            </div>
            <div style="clear:both"></div>
        </div>
    </div>
</div>
<script>
    $(function(){
        $('input[name*=ids]').click(function(){
            if ($('input[name*=ids]').length == $('input[name*=ids]:checked').length) {
                $('.checkAll').prop('checked','checked');
            } else {
                $('.checkAll').prop('checked', false);
            }
        });
        $('input[type=checkbox].checkAll').click(function(){
            $('input[type=checkbox]').prop('checked',this.checked);
        });
    });
    
    $(document).ready(function(){
        // 表格行点击选中切换
        $('#flexigrid > table>tbody >tr').click(function(){
            $(this).toggleClass('trSelected');
        });

        // 点击刷新数据
        $('.fa-refresh').click(function(){
            location.href = location.href;
        });
    });

    //修改是否默认
    // function changeSortOrder(id) {
    //     var url = "{:url('Citysite/setSortOrder')}";
    //     $.ajax({
    //         type: 'POST',
    //         url: url,
    //         data: {id:id,_ajax:1},
    //         dataType: 'json',
    //         success: function(res) {
    //             if (res.code == 1) {
    //                 layer.msg(res.msg, {icon: 1, time:1000}, function(){
    //                     window.location.reload();
    //                 });
    //             } else {
    //                 layer.msg(res.msg, {icon: 5}, function(){
    //                     window.location.reload();
    //                 });
    //             }
    //         },
    //         error:function (e) {
    //             showErrorAlert(e.responseText);
    //         }
    //     });
    // }
 
    /**
     * 关闭当前弹窗
     */
    function closeIframes(obj) {
        parent.layer.close(parentObj);
    }

    // 是否启用
    function setStatus(obj)
    {
        var src = "";
        if($(obj).hasClass('no')) // 图片点击是否操作
        {
            var text = "<i class='fa fa-check-circle'></i>是";
            if ($(obj).attr('data-yestext')) {
                text = $(obj).attr('data-yestext');
            }
            var value = 1;
            try {  
                if ($(obj).attr('data-value')) {
                    value = $(obj).attr('data-value');
                }
            } catch(e) {  
                // 出现异常以后执行的代码  
                // e:exception，用来捕获异常的信息  
            } 
                
        }else if($(obj).hasClass('yes')){ // 图片点击是否操作
            var text = "<i class='fa fa-ban'></i>否";
            if ($(obj).attr('data-notext')) {
                text = $(obj).attr('data-notext');
            }
            var value = 0;
            try {  
                if ($(obj).attr('data-value')) {
                    value = $(obj).attr('data-value');
                }
            } catch(e) {  
                // 出现异常以后执行的代码  
                // e:exception，用来捕获异常的信息  
            } 
        }else{ // 其他输入框操作
            var value = $(obj).val();
        }

        var id = $(obj).attr('data-id');
        var status = value;
        $.ajax({
            type: 'POST',
            url: eyou_basefile + "?m="+module_name+"&c=Citysite&a=setStatus&lang"+__lang__,
            data: {id:id, status:status, _ajax:1},
            dataType: 'json',
            success: function(res){
                if (res.code == 1) {
                    if ($(obj).hasClass('no')) {
                        $(obj).removeClass('no').addClass('yes');
                        $(obj).html(text);
                    }else if($(obj).hasClass('yes')) {
                        $(obj).removeClass('yes').addClass('no');
                        $(obj).html(text);
                    }
                    layer.msg(res.msg, {icon: 1, time: 500});
                } else {
                    var time = parseFloat(res.wait) * 1000;
                    layer.msg(res.msg, {icon: 5, time: time}, function(){
                        window.location.reload();
                    });  
                }
            }
        }); 
    }

</script>

{include file="public/footer" /}